﻿@{
    var g = "Menu" + Guid.NewGuid().ToString("N");
    var subjects = ViewBag.Subjects as IEnumerable<QizSubject>;
    var cursubj = subjects.FirstOrDefault(v => v.ID == Model);
    if (null == cursubj) { cursubj = new QizSubject(); }
    
@*@Html.DropDownListFor(m => m, new SelectList(new QizSubject[] { cursubj }, "ID", "Title"), cursubj)*@
    <span>
        <div id="(@g)_title">
        </div>
        @Html.HiddenFor(v => Model, new { id=g+"_value"})
        <ul id="@g">
            @foreach (var subj in subjects.Where(v => v.ParentQizSubject == null && (v.SubjectType == null || v.SubjectType == "常规随访单")).OrderByDescending(v => v.SortIdx))
            {
                <li><a href="#@subj.ID">@subj.Title</a>
                    @if (subj.SubQizSubjects.Count > 0)
                    {
                        <ul>
                            @foreach (var subjlv2 in subj.SubQizSubjects.OrderByDescending(v => v.SortIdx))
                            {
                                <li><a href="#@subjlv2.ID">@subjlv2.Title</a></li>
                            }
                        </ul>
                    }
                </li>
            }
        </ul>
        <script type="text/javascript">
                    $("#@g").treeview();
        </script>
    </span>

}
